﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Clinic.Observable
{
    internal static class Configuration
    {
        /// <summary>
        /// The configuration property name for <see cref="IsINotifyPropertyChangingDisabled"/>.
        /// </summary>
        private const string DisableINotifyPropertyChangingSupport = "MVVMTOOLKIT_DISABLE_INOTIFYPROPERTYCHANGING";

        /// <summary>
        /// Indicates whether or not support for <see cref="INotifyPropertyChanging"/> is disabled.
        /// </summary>
        public static readonly bool IsINotifyPropertyChangingDisabled = GetConfigurationValue(DisableINotifyPropertyChangingSupport);

        /// <summary>
        /// Gets a configuration value for a specified property.
        /// </summary>
        /// <param name="propertyName">The property name to retrieve the value for.</param>
        /// <returns>The value of the specified configuration setting.</returns>
        private static bool GetConfigurationValue(string propertyName)
        {
            if (AppContext.TryGetSwitch(propertyName, out bool isEnabled))
            {
                return isEnabled;
            }

            return false;
        }
    }
}
